package com.bowen.chapter06;

import com.bowen.except.EmployeeTypeInValidException;

public class Employee {

    /**
     * 员工姓名
     */
    protected String name;

    /**
     * 员工类型
     */
    protected String type;

    public Employee(String name, String type) throws EmployeeTypeInValidException {
        this.validateType(type);
        this.name = name;
        this.type = type;
    }

    private void validateType(String type) throws EmployeeTypeInValidException {
        String types = "engineer|salesman";
        if (types.indexOf(type) == -1)
            throw new EmployeeTypeInValidException();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
